﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using log4net;
using System.Configuration;
//[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net", Watch = true)]
namespace S3.Common
{
    public class SSDLoggingHandler : Exception, IDisposable
    {        
        //private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private const string MSG_BIZ_DEBUG = "Biz layer: {0}. {1}";
        private const string MSG_DAL_DEBUG = "Data Access layer: {0}. {1}";
        private const string MSG_PRESENTATION_DEBUG = "Presentation layer: {0}. {1}";
                

        public void BizException(string message, Exception innerException, bool isThrowException)
        {
            //log4net.Config.BasicConfigurator.Configure();

            ////Store log message to file
            //var exceptionMsg = "";
            //if (innerException != null)
            //{
            //    exceptionMsg = innerException.Message;
            //}
            //if (log.IsDebugEnabled) log.DebugFormat(MSG_BIZ_DEBUG, message, exceptionMsg);
            ////Throw exception
            ////if (isThrowException)
            //    throw new Exception(message);
        }

        public void DalException(string message, Exception innerException, bool isThrowException)
        {
            //log4net.Config.BasicConfigurator.Configure();
            ////Store log message to file
            //var exceptionMsg = "";
            //if (innerException != null)
            //{
            //    exceptionMsg = innerException.Message;
            //}
            ////if (log.IsDebugEnabled) 
            //    log.DebugFormat(MSG_DAL_DEBUG, message, exceptionMsg);

            ////Throw exception
            //if (isThrowException) throw new Exception(message);
        }

        public void PresentationException(string message, Exception innerException, bool isThrowException)
        {
            //log4net.Config.BasicConfigurator.Configure();
            ////Store log message to file
            
            //var exceptionMsg = "";
            //if (innerException != null)
            //{
            //    exceptionMsg = innerException.Message;
            //}
            ////if (log.IsDebugEnabled) 
            //    log.DebugFormat(MSG_PRESENTATION_DEBUG, message, exceptionMsg);

            ////Throw exception
            //if (isThrowException) throw new Exception(message);
        }

        public void TraceInfo(string message)
        {
            //log4net.Config.BasicConfigurator.Configure();
            ////if (log.IsInfoEnabled) 
            //    log.Info(message);
        }

        
        public void TraceError(string message)
        {
            //log4net.Config.BasicConfigurator.Configure();
            ////if (log.IsErrorEnabled) 
            //    log.Info(message);
        }

        public void Dispose()
        {
            //if (log.IsDebugEnabled) log.DebugFormat(this.Message);
            //throw new Exception("Server Error !");

        }
    }
}
